﻿@using Microsoft.FluentUI.AspNetCore.Components.Tests.Extensions
@using Xunit
@inherits TestContext


@code
{
    [Inject]
    public GlobalState GlobalState { get; set; } = new GlobalState();

    public FluentAppBarItemTests()
    {
        JSInterop.Mode = JSRuntimeMode.Loose;

        Services.AddSingleton(GlobalState);
        Services.AddSingleton(LibraryConfiguration.ForUnitTests);
    }

    [Fact]
    public void FluentAppBarItem_ChildContent()
    {
        // Arrange

        // Act
        var cut = Render<FluentAppBarItem>(
            @<FluentAppBar>
                <FluentAppBarItem Href="/" IconRest="@(new SampleIcons.Samples.Info())" Text="My item">
                    <div>Child content</div>
                </FluentAppBarItem>
            </FluentAppBar>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentAppBarItem_Default()
    {
        // Arrange

        // Act
        var cut = Render<FluentAppBarItem>(
            @<FluentAppBar>
                <FluentAppBarItem Href="/" Text="My item" IconRest="@(new SampleIcons.Samples.Info())">
                </FluentAppBarItem>
            </FluentAppBar>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentAppBarItem_NoText()
    {
        // Arrange

        // Act
        var cut = Render<FluentAppBarItem>(
            @<FluentAppBar>
                <FluentAppBarItem Href="/" IconRest="@(new SampleIcons.Samples.Info())">
                </FluentAppBarItem>
            </FluentAppBar>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentAppBarItem_IconActive()
    {
        // Arrange

        // Act
        var cut = Render<FluentAppBarItem>(
            @<FluentAppBar>
                <FluentAppBarItem Href="/" Text="My item" IconRest="@(new SampleIcons.Samples.Info())" IconActive="@(new SampleIcons.Samples.Warning())">
                </FluentAppBarItem>
            </FluentAppBar>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentAppBarItem_Tooltip()
    {
        // Arrange

        // Act
        var cut = Render<FluentAppBarItem>(
            @<FluentAppBar>
                <FluentAppBarItem Href="/" Text="My item" IconRest="@(new SampleIcons.Samples.Info())" IconActive="@(new SampleIcons.Samples.Warning())" Tooltip="My item tooltip">
                </FluentAppBarItem>
            </FluentAppBar>);

        // Assert
        cut.Verify();
    }
}
